import request from '@/utils/request'

// 查询用户列表
export function listUser(data) {
  return request({
    url: '/console/system/user/queryUserList',
    method: 'post',
    data: data
  })
}

// 查询用户详细
export function getUser(data) {
  return request({
    url: '/console/system/user/detail',
    method: 'post',
    data: data
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/console/system/user/addUser',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/console/system/user/updateUser',
    method: 'post',
    data: data
  })
}

// 删除用户
export function delUser(data) {
  return request({
    url: '/console/system/user/deleteUser',
    method: 'post',
    data: data
  })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    'id': userId,
    'password': password
  }
  return request({
    url: '/console/system/user/updatePwd',
    method: 'post',
    data: data
  })
}

// 用户修改密码
export function changeUserPwd(userId, password) {
  const data = {
    'id': userId,
    'password': password
  }
  return request({
    url: '/console/system/user/changePwd',
    method: 'post',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/console/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/console/system/user/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/console/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

//  激活用户
export function updateLock(userId) {
  const data = {
    'id': userId
  }
  return request({
    url: '/console/system/user/updateLock',
    method: 'post',
    data: data
  })
}

export function getUserByUserId(userId) {
  return request({
    url: '/console/system/user/querySysUserById?userId=' + userId,
    method: 'get'
  })
}

export function getUserDetailForUpdate(data) {
  return request({
    url: '/console/system/update/user/detail',
    method: 'post',
    data: data
  })
}
